package MercuryTour;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

public class registrationPage {
	
	//Define web elements
	
	@FindBy(name = "firstName")
	WebElement firstName;
	
	@FindBy(name = "lastName")
	WebElement lastName;
	
	@FindBy(name = "phone")
	WebElement phone;
	
	@FindBy(name = "userName")
	WebElement emailAddress;
	
	@FindBy(name = "address1")
	WebElement address1;
	
	@FindBy(name = "address2")
	WebElement address2;

	@FindBy(name = "city")
	WebElement city;
	
	@FindBy(name = "state")
	WebElement state;
	
	@FindBy(name = "postalCode")
	WebElement postalCode;
	
	/*Define a Select object.  Don't use below to initiate Select object
	@FindBy(name = "country")
	Select country;
	country.selectByValue();
	This will cause Nullpointer error as constructor of Select is Select(WebElement)*/
	
	@FindBy(name = "country")
	WebElement country;
	
	@FindBy(name = "email")
	WebElement userName;
	
	@FindBy(name = "password")
	WebElement password;
	
	@FindBy(name = "confirmPassword")
	WebElement confirmPassword;
	
	@FindBy(name = "register")
	WebElement registerButton;
	
	//Assign values to fields
	
	public void assignValueToTextFields (String[] textFieldsNeedForRegistration)
	
	{
		firstName.sendKeys(textFieldsNeedForRegistration[0]);
		lastName.sendKeys(textFieldsNeedForRegistration[1]);
		phone.sendKeys(textFieldsNeedForRegistration[2]);
		emailAddress.sendKeys(textFieldsNeedForRegistration[3]);
		address1.sendKeys(textFieldsNeedForRegistration[4]);
		address2.sendKeys(textFieldsNeedForRegistration[5]);
		city.sendKeys(textFieldsNeedForRegistration[6]);
		state.sendKeys(textFieldsNeedForRegistration[7]);
		postalCode.sendKeys(textFieldsNeedForRegistration[8]);
		Select selectCountryDropdownMenu = new Select(country);
		selectCountryDropdownMenu.selectByValue(textFieldsNeedForRegistration[9]);
		userName.sendKeys(textFieldsNeedForRegistration[10]);
		password.sendKeys(textFieldsNeedForRegistration[11]);
		confirmPassword.sendKeys(textFieldsNeedForRegistration[12]);
		
	}
	
	//Click Register button
	
	public void clickRegisterButton()
	
	{
		registerButton.click();
	}
	
}
